#ifndef MEASURE_SIZE_TRACKER_BOUNDS_VISITOR_H_
#define MEASURE_SIZE_TRACKER_BOUNDS_VISITOR_H_

#if defined(_MSC_VER)
#pragma once
#endif

#include "geometry_elements.h"
#include "boost\variant\static_visitor.hpp"
#include <algorithm>

class bounds_visitor : public boost::static_visitor<box_2>
{
public:

  bounds_visitor(void)
  {
  }

  ~bounds_visitor(void)
  {
  }

public:

  box_2 operator()(const point_2& point) const
  {
    return box_2(point, 3);
  }

  box_2 operator()(const segment_2& segment) const
  {
    point_2 topLeft(std::min(segment.start.x, segment.end.x),
      std::min(segment.start.y, segment.end.y));
    point_2 bottomRight(std::max(segment.start.x, segment.end.x),
      std::max(segment.start.y, segment.end.y));

    return box_2(topLeft, bottomRight);
  }

  box_2 operator()(const box_2& box) const
  {
    return box;
  }

  box_2 operator()(const angle_box_2& angle_box) const
  {
    return angle_box.bounds();
  }

  box_2 operator()(const ring_2& ring) const
  {
    return box_2(point_2(ring.center_x, ring.center_y), ring.radius*2);
  }

  box_2 operator()(const arc_2& arc) const
  {
    return arc.bounds();
  }

  box_2 operator()(const annulus_2& annulus) const
  {
    return annulus.bounds();
  }

  box_2 operator()(const annulus_arc_2& annulus_sector) const
  {
    return annulus_sector.bounds();
  }

  box_2 operator()(const polygon_2& polygon) const
  {
    return polygon.bounds();
  }
};

#endif // MEASURE_SIZE_TRACKER_BOUNDS_VISITOR_H_